﻿#ifndef COMFUNC_H
#define COMFUNC_H
#include<QString>
#include<QByteArray>
#include<QFile>
#include<QTextStream>
#include<Windows.h>
#include<QMutex>

class ComFunc
{
public:
    ComFunc();
    ~ComFunc();

    static void LogFileInit();
    static void LogFileRelease();

    ///判断Qstring中是不是纯数字
    static int isDigitStr(QString src);
	static QString GetCofcoStatusName(int iStatus);
	static QString GetCofcoOrderType(int iType);
	static QString GetBSName( int iBS);
	static QString GetOCName( int iOC);
	static QString GetHedgeType( int cHedge);
	static QString GetCurrTime();
	///报单通知写入Log文件
    static QString    OutputInfoMessage(int entrustNo,const char* contractCode, const char* entrustRef,char status);
	///报单插入写入Log文件
    static void    OutputInsertMessage(const char* contract_code,const char* orderRef);
	///成交回报写入Log文件
    static void    OutputSuccessMessage();

    static void    OutputErrMessage(QString msg);

    static LARGE_INTEGER getFILETIMEoffset();
    static __int64 GetHighAccuracyMicros();
    static int clock_gettime(int X, struct timeval *tv);
    //将微秒数时间戳格式化成"yyyy-MM-dd hh:mm:ss zzz uuu"
    static std::string GetDateString();

private:
    static QFile*        m_LogFile;

    static LARGE_INTEGER m_OrderStartTime;
    static int           m_iLogIndex;
    static int           m_iOrderRef;

    static QMutex        m_mutex;
};

#endif // COMFUNC_H
